from framework.interface.abstract_api import AbstractApi
from marshmallow import Schema, fields


# 请访问：http://106.53.97.117:7777/v1/select-apikey

#  获取中华香烟品牌
class SelectApikey(AbstractApi):


    # 参数 模式
    class GetSchema(Schema):
        model = fields.Str(required=True)

    # 请求体
    def handle_get_request(self):
        model = self.get_param("model",default="gpt-3.5-turbo-16k-0613")
        if model =="gpt-4o-2024-05-13":
            sql = f"""select * from apikey_model where status = 1 and open_model ='{model}'"""
        else:
            sql = f"""select * from apikey_model where status = 1 and open_model like '%{model}%'"""
        msg = self.sql_db.first(sql)
        return msg
